package cn.db.tools.dbtools.message;

import javafx.util.Duration;
import org.pomo.toasterfx.ToastBarToasterService;
import org.pomo.toasterfx.model.ToastParameter;
import org.pomo.toasterfx.model.impl.ToastTypes;

/**
 * @author zooy
 * @create 2023-08-06 3:17
 * @description
 */
public class ToastMessage {

    private static ToastMessage instance;

    private ToastBarToasterService service;

    private ToastMessage() {
        service = new ToastBarToasterService();
        service.initialize();
    }

    public void popMessage(String text, ToastTypes toastType) {

        // 你可以在任何线程中，调用此方法。
        service.bomb("通知消息", text, ToastParameter.builder().timeout(Duration.seconds(3)).build(), ToastTypes.INFO);

    }

    public static ToastMessage getInstance() {

        if (instance == null) {
            synchronized (ToastMessage.class) {
                if (instance == null) {
                    instance = new ToastMessage();
                }
            }
        }

        return instance;
    }




}
